{{template "header.html" .}}
<div id="form-result-message">
    <div class="message success hide">用户信息已更新</div>
    <div class="message error hide">用户信息更新失败：<span></span></div>
</div>
<div class="container" id="user-add-form-container">
    <div id="user-add-header" class="clear">
        <h1 class="h1 left">编辑用户 "{{.User.real_name}}"</h1>
    </div>
    <form id="user-add-form" class="form clear" action="/admin/users/edit/{{.User.id}}/" method="post">
        <div class="meta left">
            <p class="item">
                <label for="user-add-nick">昵称</label>
                <input id="user-add-nick" class="ipt" type="text" name="real_name" value="{{.User.real_name}}"/>
            </p>
            <p class="item clear">
                <label for="user-add-desc" class="left">个人介绍</label>
                <textarea class="left ipt" name="bio" id="user-add-desc">{{.User.bio}}</textarea>
            </p>{{if ne .User.role_name "admin"}}
            <p class="item">
                <label for="user-add-status">状态</label>
                <select name="status" id="user-add-status" class="select">
                    {{if eq .User.status "active"}}<option value="active" selected>启用</option>{{else}}<option value="active">启用</option>{{end}}
                    {{if eq .User.status "inactive"}}<option value="inactive" selected>不启用</option>{{else}}<option value="inactive">不启用</option>{{end}}
                </select>
            </p>
            <p class="item">
                <label for="user-add-role">角色名</label>
                <select name="role_name" id="user-add-role" class="select">
                    {{if eq .User.role_name "editor"}}<option value="editor" selected>编辑</option>{{else}}<option value="editor">编辑</option>{{end}}
                    {{if eq .User.role_name "reader"}}<option value="reader" selected>读者</option>{{else}}<option value="reader">读者</option>{{end}}
                </select>
            </p>{{else}}
            <p class="item"><label></label>管理员不能改变状态和角色，也不能删除自己</p>{{end}}
            <p class="item submit">
                <button class="btn save" id="user-add-submit">更新</button>{{if ne .User.role_name "admin"}}
                <button class="btn delete" id="user-delete-btn">删除</button>{{end}}
            </p>
        </div>
        <div class="account left">
            <p class="item">
                <label for="user-add-account">用户名</label>
                <input id="user-add-account" class="ipt" type="text" name="user" value="{{.User.user}}"/>
            </p>
            <p class="item">
                <label for="user-add-password">登录密码</label>
                <input id="user-add-password" class="ipt" type="password" name="password"/>
            </p>
            <p class="item">
                <label for="user-add-email">邮件</label>
                <input id="user-add-email" class="ipt" type="email" name="email" value="{{.User.email}}"/>
            </p>
            <p class="item">
                <label for="user-add-url">联系网址</label>
                <input id="user-add-url" class="ipt" type="url" name="url" value="{{.User.url}}"/>
            </p>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        ajaxForm("#user-add-form");
    });
</script>
</body>
</html>